
SET T_CLK = 16;                 // 16us
SET T_SETUP = 8;                // Set T_SETUP = 40% x T_CLK ~ 60% x T_CLK
CS_SPI = 0;                     // Chip Select get low
RESET_SPI = 0;                  // RESET get low
Delay(10);                      // T_VCC_ON > 10 ms

//Reset Display TCON
CS_SPI = 1;                     // Chip Select get high
RESET_SPI = 1;                  // RESET get high
Delay_ms(5);                    // Delay get high
RESET_SPI = 0;                  // RESET get low
Delay_ms(5);                    // Delay 5 ms
RESET_SPI = 1;                  // RESET get high
Delay_ms(19);                   // T_RESET_CS > 19 ms


CS_SPI = 0;                     // Chip Seselct get low
Delay_ms(1);                    // Delay T_CS_SI > 1ms; T_RESET_CS + T_CS_SI >= 20 ms

//Send Header Byte
Send_Data(0x03);                
Send_Data(0xA0);                // Send Header Byte ID = 0x03A0(for 1.44,2 and 2.7" EPD)
Delay_ms(120);                  // 120 ms =< T_DELAY1 => 400 ms

//Transmit Display Pattern
for (int i = 0; i < 176; i++) {         // 2.7" EPD resolution = 264 x 176
    for (int i = 0; i < 16; i++) {      // 1 Line of Pixels, 264/8/2 = 16.5 Bytes
        Send_Data(0xFF);                // Byte 1, Black for example 
        Send_Data(0xFF);                // Byte 2, Black for example
        Delay_ms(100);                  //  T_DELAY2 = 1xT_CLK us after every 2 bytes
    }
    Send_Data(0xFF);                    // Send last 8 bits(1 Byte) od pixels
    WriteSPI(0x00);                     //  Last 8 bits of line must be 00 fpr 2.7" EPD                  
    Delay_ms(1);                        // T_DELAY3 = 1ms after each line
}

//Update Display
while (BUSY_SPI = 1) {
    CS_SPI = 1;                         // Chip Select get high
    Delay_s(2.5);                       // T_UPDATE = 2.5 ~ 5 seconds
}

Delay_ms(500);                          // T_VCC_OFF <= 500 ms
V_CC & V_DD = OFF                       // Please make sure power and signal need to be set to OFF